package pub.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Function entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "function", catalog = "sddf")
public class Function implements java.io.Serializable {

	// Fields

	private Integer id;
	private String name;
	private Integer leave;
	private Integer father;
	private String icon;
	private String url;
	private Set<Rolefunction> rolefunctions = new HashSet<Rolefunction>(0);

	// Constructors

	/** default constructor */
	public Function() {
	}

	/** minimal constructor */
	public Function(String name, Integer leave) {
		this.name = name;
		this.leave = leave;
	}

	/** full constructor */
	public Function(String name, Integer leave, Integer father, String icon, String url, Set<Rolefunction> rolefunctions) {
		this.name = name;
		this.leave = leave;
		this.father = father;
		this.icon = icon;
		this.url = url;
		this.rolefunctions = rolefunctions;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 10)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "leave", nullable = false)
	public Integer getLeave() {
		return this.leave;
	}

	public void setLeave(Integer leave) {
		this.leave = leave;
	}

	@Column(name = "father")
	public Integer getFather() {
		return this.father;
	}

	public void setFather(Integer father) {
		this.father = father;
	}

	@Column(name = "icon", length = 50)
	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@Column(name = "url", length = 50)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "function")
	public Set<Rolefunction> getRolefunctions() {
		return this.rolefunctions;
	}

	public void setRolefunctions(Set<Rolefunction> rolefunctions) {
		this.rolefunctions = rolefunctions;
	}

}